<template>
  <div class="workReportRecord">
    <el-table :data="data?data.proFeedbackVOList:null" border style="width: 100%" height="300px" size="small">
      <el-table-column label="序号" align="center" type="index" width="50" />
      <el-table-column label="报工人员" show-overflow-tooltip align="center" prop="fbNickName" />
      <el-table-column label="报工数量" show-overflow-tooltip align="center" prop="quantityFeedback" />
      <el-table-column label="报工时间" show-overflow-tooltip align="center" prop="feedbackTime" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.feedbackTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="检验日期" show-overflow-tooltip align="center" prop="inspectDate" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.inspectDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="合格" show-overflow-tooltip align="center" prop="quantityQualified" />
      <el-table-column label="不合格" show-overflow-tooltip align="center" prop="quantityUnquanlified" />   
      <el-table-column label="合格率" show-overflow-tooltip align="center" prop="qualifiedRate" />
      <el-table-column label="检测结果" show-overflow-tooltip align="center" prop="checkResult" />
      <el-table-column label="质检状态" show-overflow-tooltip align="center" prop="checkStatus" />
      <!-- <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="text" size="mini" v-if="!scope.row.checkStatus" @click="handleQualityTesting(scope.row)">{{scope.row.checkStatus ? '取消' : '质检'}}</el-button>
          <el-button type="text" size="mini" v-if="scope.row.checkStatus" @click="handleSee(scope.row)">查看</el-button>
          <el-button type="text" size="mini" v-if="!scope.row.checkStatus" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column> -->
    </el-table>

    <!-- <pagination 
      v-show="total>0"  
      :total="total" 
      :page.sync="queryParams.pageNum" 
      :limit.sync="queryParams.pageSize" 
      @pagination="getList"
    /> -->
    <div>
      报工总数：{{ data?data.quantityFeedbackTotal:0 }}，合格数：{{ data?data.quantityQualifiedTotal:0 }}，不合格数：{{ data?data.quantityUnqualifiedTotal:0 }}，合格率：{{ data?data.qualifiedRateTotal+'%':'' }}
    </div>
    <el-dialog title="查看报工记录" :visible.sync="dialogVisible" width="700px" append-to-body>
      <el-form ref="form" :model="form"  label-width="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="报工类型" prop="feedbackType">
              <el-select v-model="form.feedbackType" disabled>
                <el-option 
                  v-for="dict in dict.type.mes_feedback_type" 
                  :key="dict.value" 
                  :label="dict.label" 
                  :value="dict.value" 
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工作站" prop="workstationName">
              <el-input v-model="form.workstationName" disabled  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="生产工单编号" prop="workorderCode">
              <el-input v-model="form.workorderCode" disabled  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产品物料编码" prop="itemCode">
              <el-input v-model="form.itemCode" disabled  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="产品物料名称" prop="itemName">
              <el-input v-model="form.itemName" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格型号" prop="specification">
              <el-input v-model="form.specification" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="报工数量" prop="quantityFeedback">
              <el-input v-model="form.quantityFeedback" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报工人" prop="nickName">
              <el-input v-model="form.nickName" disabled  />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="合格品数量" prop="quantityQualified">
              <el-input v-model="form.quantityQualified" disabled  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="不良品数量" prop="quantityUnquanlified">
              <el-input v-model="form.quantityUnquanlified" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="待检测数量" prop="quantityUncheck">
              <el-input v-model="form.quantityUncheck" disabled  />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="返工数量" prop="quantityRework">
              <el-input v-model="form.quantityRework" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { listFeedback, getFeedback, delFeedback, addFeedback, updateFeedback, execute, cancelQCFeedback } from "@/api/mes/pro/feedback";
export default {
  name: 'workReportRecord',
  dicts:[ 'mes_feedback_type', 'mes_order_status' ],
  props: {
    data: undefined,
  },
  data() {
    return {
      total: 0,
      queryParams:{
        pageNum: 1,
        pageSize: 10
      },
      tableData:[],
      dialogVisible: false,
      form: {},
      feedbackType:''
    }
  },
  mounted() {
    // listFeedback(this.queryParams).then(response => {
      // })
      // this.getList()
      // console.log('>>>', this.dict.type.mes_feedback_type);
  },
  methods: {
    // getList(){
    //   listFeedback(this.queryParams).then(response => {
    //     this.tableData = response.rows
    //     this.total = response.total
    //     console.log('???',response);
    //   })
    // },
    handleDelete(row){
      this.$modal.confirm('是否确认删除数据项？').then(()=>{
        delFeedback(row.recordId).then(response => {
          this.$modal.msgSuccess("删除成功");
          this.$emit('handleClick', {name: '5'})
          // this.getList();
        })
      })
      console.log(row);
    },
    handleSee(row){
      this.dialogVisible = true
      this.form = {...row}
      console.log(row);
    },
    handleQualityTesting(row){
      if(!row.checkStatus){
        this.$router.push('/mes/qc/ipqc')
      }else{
        this.$modal.confirm('是否确认取消质检？').then(()=>{
          cancelQCFeedback(row.recordId).then(res=>{
            this.$modal.msgSuccess("取消成功");
            this.$emit('handleClick', {name: '5'})
          })
          console.log('qqq123');
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>